#!/usr/bin/perl

$NUM = `/opt/tivoli/tsm/client/ba/bin/dsmadmc  -id=opmon -password=opdbmon 'q req' | grep Mount | wc –l`;

if ($NUM == 1) {
       	$DRV1 = `/opt/tivoli/tsm/client/ba/bin/dsmadmc  -id=opmon -password=opdbmon 'q req' | grep Mount | cut -f10 -d" "`;
	$VOL1 = `/opt/tivoli/tsm/client/ba/bin/dsmadmc  -id=opmon -password=opdbmon 'q req' | grep Mount | cut -f6 -d" "`;
 	print = "CRITICAL - Drive $DRV1 solicitando fita $VOL1\n";
	exit 2;
}elsif ($NUM == 2) {
	$DRV1 = `/opt/tivoli/tsm/client/ba/bin/dsmadmc  -id=opmon -password=opdbmon 'q req' | grep Mount | cut -f10 -d" "`;
        $VOL1 = `/opt/tivoli/tsm/client/ba/bin/dsmadmc  -id=opmon -password=opdbmon 'q req' | grep Mount | cut -f6 -d" "`;
	$DRV2 = `/opt/tivoli/tsm/client/ba/bin/dsmadmc  -id=opmon -password=opdbmon 'q req' | grep Mount | cut –f27 -d" "`;
	$VOL2 = `/opt/tivoli/tsm/client/ba/bin/dsmadmc  -id=opmon -password=opdbmon 'q req' | grep Mount | cut –f24 -d" "`;
	print "CRITICAL - Drive $DRV1 solicitando fita $VOL1, e Drive $DRV2 solicitando fita $VOL2\n";
	exit 2;
}elsif ($NUM == 0) {
	print "OK - Nenhuma requisicao pendente\n";
	exit 0;	
}else {
	print "UNKNOWN - Saida desconhecida\n";
	exit 3;
}
